Ext.define('SKJF.view.PENJUALAN.v_penawaran_form', {
	extend	: 'Ext.form.Panel',
	
	alias	: 'widget.v_penawaran_form',
	
	// region:'east',
	// id: 'east-region-container',
	
	title		: 'Create/Update penawaran',
    bodyPadding	: 5,
    autoScroll	: true,
    
    initComponent: function(){
    	/*
		 * Deklarasi variable setiap field
		 */
		
		var currency_store = Ext.create('SKJF.store.s_mstcurrency',{autoLoad:true});
		
		var mstcustomer_store = Ext.create('SKJF.store.s_mstcustomer',{autoLoad:true});
		
		var APA_PEMBELIAN_store = Ext.create('Ext.data.Store', {
			fields: ['value', 'display'],
			data : [{"value":"YA", "display":"YA"},{"value":"TIDAK", "display":"TIDAK"}]
		});
		 
		 var NOMOR_QUOTE_field = Ext.create('Ext.form.field.Text', {
			itemId: 'NOMOR_QUOTE_field',
			name: 'NOMOR_QUOTE',
			fieldLabel: 'NOMOR_QUOTE',
			allowBlank: true,
			readOnly: true
		});
		var TANGGAL_QUOTE_field = Ext.create('Ext.form.field.Date', {
			itemId: 'TANGGAL_QUOTE_field',
			name: 'TANGGAL_QUOTE', /* column name of table */
			format: 'Y-m-d',
			fieldLabel: 'TANGGAL_QUOTE'
		});
		var NAMA_CUSTOMER_field = Ext.create('Ext.form.field.ComboBox', {
			name: 'NAMA_CUSTOMER', /* column name of table */
			fieldLabel: 'NAMA_CUSTOMER',
			pageSize: 10,
			typeAhead    : true,
			triggerAction: 'all',
			selectOnFocus: true,
            loadingText  : 'Searching...',
			store: mstcustomer_store,
			queryMode: 'local',
			tpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'<div class="x-boundlist-item">{NAMA_CUSTOMER} - {TELPON}</div>',
				'</tpl>'
			),
			displayTpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'{NAMA_CUSTOMER} - {TELPON}',
				'</tpl>'
			),
			valueField: 'NAMA_CUSTOMER',
			displayField: 'NAMA_CUSTOMER'
		});
		var APA_PEMBELIAN_field = Ext.create('Ext.form.field.ComboBox', {
			name: 'APA_PEMBELIAN', /* column name of table */
			fieldLabel: 'APA_PEMBELIAN',
			store: APA_PEMBELIAN_store,
			queryMode: 'local',
			displayField: 'display',
			valueField: 'value'
		});
		var CURRENCY_field = Ext.create('Ext.form.field.ComboBox', {
			name: 'CURRENCY', /* column name of table */
			fieldLabel: 'CURRENCY',
			pageSize: 10,
			typeAhead    : true,
			triggerAction: 'all',
			selectOnFocus: true,
            loadingText  : 'Searching...',
			store: currency_store,
			queryMode: 'local',
			tpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'<div class="x-boundlist-item">{CURRENCY} - {NEGARA}</div>',
				'</tpl>'
			),
			displayTpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'{CURRENCY} - {NEGARA}',
				'</tpl>'
			),
			valueField: 'CURRENCY',
			displayField: 'CURRENCY'
		});
		var INFO_field = Ext.create('Ext.form.field.Text', {
			name: 'INFO', /* column name of table */
			fieldLabel: 'INFO',
			maxLength: 50 /* length of column name */
		});		
        Ext.apply(this, {
            fieldDefaults: {
                labelAlign: 'right',
                labelWidth: 120,
                msgTarget: 'qtip',
				anchor: '100%'
            },
			defaultType: 'textfield',
            items: [NOMOR_QUOTE_field,TANGGAL_QUOTE_field,NAMA_CUSTOMER_field,APA_PEMBELIAN_field,CURRENCY_field,INFO_field],
			
	        buttons: [{
                iconCls: 'icon-save',
                itemId: 'save',
                text: 'Save',
                disabled: true,
                action: 'save'
            }, {
                iconCls: 'icon-add',
				itemId: 'create',
                text: 'Create',
                action: 'create'
            }, {
                iconCls: 'icon-reset',
                text: 'Cancel',
                action: 'cancel'
            }]
        });
        
        this.callParent();
    },
	
	getCf: function(){
        return 'Eko';
    }
});